package Export;

/**
 * @description:
 * @author: cyy
 **/
public class methodJxl {

    /*
    *  public static void exportFaceDirEquipmentReport(List<Map<String,Object>> list,String state, HttpServletRequest request, HttpServletResponse response){
        //表名
        Map<String,Object> map1 = new HashMap<>();
        map1.put("allstate","合格设备表");
        map1.put("codestate","编码异常设备表");
        map1.put("civilstate","行政区划异常设备表");
        map1.put("jwstate","经纬度异常设备表");
        //异常
        Map<String,Object> map2 = new HashMap<>();
        map2.put("allstate","异常");
        map2.put("codestate","编码不合适");
        map2.put("civilstate","行政区划不合适");
        map2.put("jwstate","经纬度不合适");
        //导出路径
        String titleName = "人脸卡口"+map1.get(state);
        StringBuffer buffer = new StringBuffer();
        buffer.append(titleName);
        SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
        buffer.append(format.format(new Date())); // 导出时间
        String userAgent = request.getHeader("USER-AGENT");
        Workbook wbin = null;
        WritableWorkbook createWorkbook = null;
        try {
            ServletOutputStream os = WeekReportUtil.setResponseFile(buffer.toString(), ".xls", response, userAgent);
            //模板路径
            String fileSaveRootPath = request.getSession().getServletContext().getRealPath("/")+"upload/人脸卡口"+map1.get(state)+".xls";
            wbin = Workbook.getWorkbook(new File(fileSaveRootPath));
            createWorkbook = Workbook.createWorkbook(os, wbin);
            WritableSheet sheet = createWorkbook.getSheet(0);
            for (int i = 0; i < list.size(); i++) {
                Map<String,Object> map = list.get(i);
                Label label1 = new Label(0, i+3, map.get("devicecode")+"");
                Label label2 = new Label(1, i+3, map.get("devicename")+"");
                Label label3 = new Label(2, i+3, "摄像机");
                Label label4 = new Label(3, i+3, map.get("civilcode")+"");
                Label label5 = new Label(4, i+3, map.get("civilname")+"");
                Label label6 = new Label(5, i+3, map.get("jd")+"");
                Label label7 = new Label(6, i+3, map.get("wd")+"");
                String equipmentState = "";
                if(Integer.parseInt(map.get(state).toString()) == 0){
                    equipmentState = map2.get(state).toString();
                }else {
                    equipmentState = "正常";
                }
                Label label8 = new Label(7, i+3, equipmentState);
                sheet.addCell(label1);
                sheet.addCell(label2);
                sheet.addCell(label3);
                sheet.addCell(label4);
                sheet.addCell(label5);
                sheet.addCell(label6);
                sheet.addCell(label7);
                sheet.addCell(label8);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                createWorkbook.write();
                createWorkbook.close();
            } catch (WriteException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    * */
}
